package com.it.day3;

/**
 * ClassName: HeapSpaceInitial
 * Description: 查看heap默认内存量
 *
 * @Author: csx
 * @Create: 2025/4/27 - 9:30
 * @version: v1.0
 */
public class HeapSpaceInitial {
    public static void main(String[] args) {
        //返回JVM中的堆初始内存总量（Runtime.getRuntime() 获取运行时对象实例）
        long initialMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024;
        //返回JVM试图使用的最大堆内存量
        long maxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024;

        System.out.println("-Xms : " + initialMemory + "M");
        System.out.println("-Xmx : " + maxMemory + "M");

        System.out.println("系统内存大小为：" + initialMemory * 64.0 / 1024 + "G");
        System.out.println("系统内存大小为：" + maxMemory * 4.0 / 1024 + "G");

        try {
            Thread.sleep(1000000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
